package com.six.goods.controller;

import com.six.core.entity.Category;
import com.six.core.vo.Result;
import com.six.goods.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: whj
 * @Version 1.0
 * @Date: 2023/2/28  9:49
 */

@RestController
@RequestMapping("/goods/category")
public class CategoryController {
    @Autowired
    private CategoryService categoryService;

    /**
     * 类别管理--分页查询
     * @param currentPage
     * @param pageSize
     * @param category
     * @return
     */
    @PostMapping("/selecategory")
    @ResponseBody
    public Result seleCategory(@RequestParam(defaultValue = "1")Integer currentPage, @RequestParam(defaultValue = "5")Integer pageSize, @RequestBody Category category){
        return categoryService.seleAllCategory(currentPage,pageSize,category);
    }

    /**
     * 类别管理--删除
     * @param id
     * @return
     */
    @DeleteMapping("/deletecategory")
    @ResponseBody
    public  Result deleteCategory( Integer id){
        return categoryService.deleteCategory(id);
    }

    /**
     * 类别管理--修改
     * @param category
     * @return
     */
    @PutMapping("/updatecategory")
    @ResponseBody
    public  Result updateCategory(@RequestBody Category category){
        return categoryService.updateCategory(category);
    }

    /**
     * 类别管理--添加
     * @param category
     * @return
     */
    @PostMapping("/insertcategory")
    @ResponseBody
    public  Result insertCategory(@RequestBody Category category){
        return categoryService.insertCategory(category);
    }

    //商品审核的下拉搜索
    @GetMapping("/selecg")
    @ResponseBody
    public  Result selecg(){
        return categoryService.seleCG();
    }

    @PostMapping("/selectByCategoryname")
    @ResponseBody
    public  Category selectByCategoryname(@RequestBody Category category){
        return categoryService.selectByCategoryname(category);
    }


}
